<template>
	<div class="speci" v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="2">
		<div class="special">
			<div class="special_list" v-for="(item,index) in specialList" :key="index" @click="goDetails(item.id)" >
				<img :src="coverUrl(item.cover)">
				<div class="special_content">
					<div class="special_name">{{item.name}}</div>
					<div class="special_text">{{item.synopsis}}</div>
				</div>
			</div>
		</div>
		<p v-if="loading" class="page-infinite-loading">
			<span>
				<mt-spinner type="fading-circle"></mt-spinner>
				加载中...
			</span> 
		</p>
		<p v-else class="loadOver">
			<span v-if="!isNull && isLast">—— 我是有底线的 ——</span>
		</p>
	</div>
</template>

<script>
import { imageUrl} from '@/utils/global.js'
import { Toast } from 'mint-ui';
import { getSpecialList } from '@/api/special.js'

export default {
	data() {
		return {
			specialList: [],
			totalPage:null,
			urlPath: imageUrl,
			listQuery: {
				pageNum: 1,
				pageSize: 5
			},
			loading:false,
			isNull: '',
			isLast: '',
		}
	},
	mounted() {
		this.getList()
	},
	methods: {
		getList() { //专题列表
			this.loading = true
			getSpecialList(this.listQuery).then(res => {
				if(res.data.code === 0) {
					var list = []
					if(this.listQuery.pageNum == 1) { //第一页
						list = res.data.data.list
					} else {
						list = this.specialList.concat(res.data.data.list)
					}
					this.specialList = list
					this.totalPage = res.data.data.pages
					this.isNull = list && list.length > 0 ? false : true
					this.isLast = res.data.data.pages == this.listQuery.pageNum ? true : false
				} else {
					Toast(res.data.msg)
				}
				this.loading = false
			})
		},
		loadMore(){
			if(this.totalPage > this.listQuery.pageNum){
				this.listQuery.pageNum = this.listQuery.pageNum + 1
				this.getList()
			}
		},
		goDetails(id) {
			this.navigationFuc('specialList',{id})
		}
	},
}
</script>

<style scoped>
.special {
  height: 100%;
  padding: 0.34rem 0.4rem 0.8rem;
}
.special_list {
  margin-top: 0.8rem;
}
.special_list:first-child {
  margin-top: 0.46rem;
}
.special_list img {
  width: 100%;
  height: 4.48rem;
  border-radius: 0.2rem;
}
.special_content {
  margin-top: 0.2rem;
}
.special_name {
  font-size: 24px;
  color: #000000;
  font-weight: 800;
  overflow: hidden;
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
  -webkit-box-orient: vertical;
  -webkit-line-clamp:1;
  text-overflow:ellipsis;
  background: url('../../assets/common/bg.png') no-repeat left bottom;
  background-size: 100% 0.17rem;
}
.special_text {
  margin-top: 0.2rem;
  font-size: 12px;
  color: #999999;
  line-height: 0.38rem;
  overflow: hidden;
  word-break: break-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp:2;
  text-overflow:ellipsis;
  display: -webkit-box;
}
</style>
<style>
.mint-spinner-fading-circle{
  margin: 0 auto;
  margin-bottom: 10px;
}
.page-infinite-loading{
  text-align: center;
  padding: 10px;
  color: #999999;
  font-size: 14px;
}
.speci .loadOver{
  height: 0.8rem;
  text-align: center;
  line-height: 0.8rem;
  color: #999999;
  padding-bottom: 1.5rem;
  font-size: 14px;
}
</style>